package com.yxy.controller.mobile;

import com.yxy.common.Result;
import com.yxy.constant.RequestMapperConstant;
import com.yxy.domain.dto.SportDTO;
import com.yxy.domain.po.SportsType;
import com.yxy.domain.vo.SportListVo;
import com.yxy.domain.vo.SportTypeVO;
import com.yxy.domain.vo.SportVO;
import com.yxy.service.SportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(RequestMapperConstant.USER_REQUEST_MAPPER + "sport")
@Slf4j
public class SportController {

    private final SportService sportService;
    public SportController(SportService sportService) {
        this.sportService = sportService;
    }

    /**
     * 获取运动类型
     * @return
     */
    @GetMapping("/getSportType")
    public Result<List<SportTypeVO>> getSportType() {
        log.info("获取运动类型");
        List<SportTypeVO> vo = sportService.getSportType();
        return Result.success("", vo);
    }

    /**
     * 获取运动信息
     * @param id
     * @return
     */
    @GetMapping("/getSport")
    public Result<SportVO> getSport(Integer id){
        log.info("获取运动信息：用户id：{}", id);
        return Result.success("", sportService.getSport(id));
    }

    /**
     * 刷新运动
     * @param sportDTO
     * @return
     */
    @PostMapping("/refreshSport")
    public Result refreshSport(@RequestBody SportDTO sportDTO){
        log.info("刷新运动：{}", sportDTO);
        sportService.refreshSport(sportDTO);
        return Result.success("");
    }

    /**
     * 获取运动详情
     * @return
     */
    @GetMapping("/detail")
    public Result<List<SportListVo>> getDetail(Integer id){
        log.info("根据运动id获取运动详情，{}", id);
        List<SportListVo> vo = sportService.getDetail(id);
        return Result.success("", vo);
    }
}
